import { getroleslist } from '@/api'
import { Message } from 'element-ui'
export default {
  state: {
    rolesList: [],
    rolesDialog: false,
    rightslist: [],
    Leafkey: [],
    userid: ''
  },
  mutations: {
    async getRolesList(state) {
      const { data: res } = await getroleslist()
      console.log(res)
      if (res.meta.status === 200) {
        state.rolesList = res.data
        // return res.data
      } else {
        Message.error('获取角色列表失败')
      }
    },
    changedialog(state, val) {
      state.rolesDialog = val
    },
    getuserid(state, val) {
      state.userid = val
    },
    getrightslist(state, val) {
      state.rightslist = val
    },
    getLeafkeys(state, val) {
      state.Leafkey.push(val.id)
      // state.Leafkey = val
    },
    clearLeafkeys(state) {
      state.Leafkey = []
    }
  },
  actions: {}
}
